package extra

import (
	"encoding/json"
	"errors"

	"codeup.aliyun.com/lsxd/zltx/adapter/sdk/adapter/shared/dto"
)

// GetQueryExtra 获取订单扩展信息
func GetQueryExtra(in dto.Query) (Extra, error) {
	var inExtra map[string]interface{}
	err := json.Unmarshal(in.Extra, &inExtra)
	if err != nil {
		return nil, err
	}

	extra, ok := inExtra["order"].(map[string]any)
	if !ok {
		return nil, errors.New("没有扩展信息")
	}
	return extra, err
}
